#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/8/25 下午9:50
# @Author  : Aries
# @Site    : 
# @File    : executeExplan.py
# @Software: PyCharm

from fabric.api import env, cd, put, run,hosts,local
#test execute sql

from util.DBUtilsTools import DBPool

dbTool = DBPool()
def testExecute():
    conn = dbTool.getConnection()
    cursor = conn.cursor()
    cursor.execute("explain select * from mysql_instances")
    result = cursor.fetchone()
    print str(result)

#test fabric

def testFabric():

    env.hosts = ["root@192.168.1.104",]
    env.user = 'root'
    env.password = '123456'
    print "ENV %s" % (env.hosts)
    for host in env.hosts:
        env.host_string = host
        with cd('/opt/app/mysql_3306/bin'):
            run('/opt/app/mysql_3306/bin/mysql --socket=/opt/app/mysql_3306/tmp/mysql3306.sock -e "use zeus;explain select * from mysql_instances;"')

    
if __name__ == "__main__":
    testFabric()